package com.culturalCenter.dataCenter.mapper.training;

import com.culturalCenter.dataCenter.customEntity.training.CustomInteractive;
import com.culturalCenter.dataCenter.customEntity.training.CustomTrainingComment;
import com.culturalCenter.dataCenter.entity.training.TrainingCommentCount;
import com.culturalCenter.dataCenter.mapper.base.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 培训评论信息统计表(TrainingCommentCount)表数据库访问层
 *
 * @author makejava
 * @since 2020-09-22 19:24:40
 */
@Mapper
public interface TrainingCommentCountMapper extends BaseMapper<TrainingCommentCount> {

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     *
     * @return 影响行数
     */
    int deleteById(@Param("id") String id);

    /**
     * 培训课程互动
     *
     * @param trainingId
     *
     * @return
     */
    List<CustomInteractive> queryByTrainingId(@Param("trainingId") String trainingId);

    /**
     * 评分百分比
     *
     * @param trainingId
     *
     * @return
     */
    List<CustomInteractive> queryGradeByTrainingId(@Param("trainingId") String trainingId);

    /**
     * 培训排名
     *
     * @param branchId
     *
     * @return
     */
    List<CustomTrainingComment> selectRank(@Param("branchId") String branchId, @Param("trainingId") String trainingId);

    /**
     * 评论信息统计
     *
     * @return
     */
    List<TrainingCommentCount> countData();

    /**
     * 该分馆的培训总数
     * @param branchId
     * @return
     */
    int countAll(@Param("branchId") String branchId);

    /**
     * 同分类培训排名
     *
     * @param branchId
     * @param trainingId
     *
     * @return
     */
    List<CustomTrainingComment> selectCategoryRankList(@Param("branchId") String branchId, @Param("trainingId") String trainingId);

    /**
     * 同分类培训数
     *
     * @param branchId
     * @param trainingId
     *
     * @return
     */
    int countCategory(@Param("branchId") String branchId, @Param("trainingId") String trainingId);

    /**
     * 统计评论星数
     *
     * @param commentCounts
     */
    void insertBatch(@Param("commentCounts") List<TrainingCommentCount> commentCounts);

}
